package com.lzq.rabbitmqdemo.java_api.work;

import com.lzq.rabbitmqdemo.java_api.constant.ConnectionConfig;
import com.lzq.rabbitmqdemo.java_api.constant.Constants;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class WorkRabbitProducer {
    public static void main(String[] args) throws Exception{
        ConnectionFactory factory = ConnectionConfig.getFactory();
        try (Connection connection = factory.newConnection();
             Channel channel = connection.createChannel()) {
            channel.queueDeclare(Constants.WORK_QUEUE_NAME, true, false, false, null);
            for (int i = 0; i < 10; i++) {
                String msg = "hello" + i;
                channel.basicPublish("",Constants.WORK_QUEUE_NAME,null,msg.getBytes());
                System.out.println(msg);
            }
        }
    }
}
